// 跳转路由

import { createRouter, createWebHistory } from "vue-router";

//导入组件
import LoginVue from '@/views/Login.vue'
import HomeVue from '@/views/Home.vue'
import UserAvatarVue from "@/views/user/UserAvatar.vue";
import UserInfoVue from "@/views/user/UserInfo.vue";
import UserResetPasswordVue from "@/views/user/UserResetPassword.vue";
import VarietyVue from "@/views/variety/Variety.vue";
import ScienceManageVue from "@/views/science/ScienceManage.vue";
import Pet from "@/views/pet/Pet.vue";
import PetAdd from "@/views/pet/PetAdd.vue";
import PetUpdate from "@/views/pet/PetUpdate.vue";

//路由转换关系
const routes = [
    { path: '/login', component: LoginVue },
    // redirect->默认加载页  children-> 子路由  path-> 路由   component->  对应的页面
    { path: '/', component: HomeVue, redirect: '/science', children: [
        {path: '/user/update', component: UserAvatarVue},
        {path: '/user/userInfo', component: UserInfoVue},
        {path: '/user/updatePwd', component: UserResetPasswordVue},
        {path: '/variety/list', component: VarietyVue},
        {path: '/science', component: ScienceManageVue},
        {path: '/pet', component: Pet},
        {path: '/pet/add', component: PetAdd},
        {path: '/pet/update', component: PetUpdate},
    ]}
]
//创建路由器
const router = createRouter({
    history:createWebHistory(),
    routes:routes,
})

//导出路由
export default router